package com.youdianda.controller;


import com.youdianda.dto.YddAdvposDTO;
import com.youdianda.dto.YddAdvposPageQueryDTO;
import com.youdianda.entity.YddAdvpos;
import com.youdianda.result.Result;
import com.youdianda.service.IYddAdvposService;
import com.youdianda.vo.YddAdvposPageQueryVO;
import com.youdianda.vo.YddAdvposVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author mosen
 * @since 2023-05-15
 */
@Slf4j
@RestController
@RequestMapping("/ydd_advpos")
@Api(tags = "广告位管理")
public class YddAdvposController {
    @Autowired
    private IYddAdvposService iYddAdvposService;

    /**
     * 广告位分页查询
     *
     * @param yddAdvposPageQueryDTO
     * @return
     */

    @GetMapping("/list")
    public Result<YddAdvposPageQueryVO> pageQuery(YddAdvposPageQueryDTO yddAdvposPageQueryDTO) {

        return iYddAdvposService.pageQuery(yddAdvposPageQueryDTO);
    }


    /**
     * 根据id查询
     * @param id
     * @return
     */
    @GetMapping("/rowInfo")
    public Result<YddAdvposVO> selectById(Integer id){
        return iYddAdvposService.selectById(id);
    }

    /**
     * 修改广告位
     * @param yddAdvposDTO
     * @return
     */
    @PostMapping("/update")
    public Result updateYddAdvpos(@RequestBody YddAdvposDTO yddAdvposDTO){

        return iYddAdvposService.updateYddAdvpos(yddAdvposDTO);
    }

    /**
     * 根据id删除广告位
     * @param id
     * @return
     */
    @GetMapping("/del")
    public Result deleteById(Integer id){

        return iYddAdvposService.deleteById(id);
    }

    /**
     * 广告列表全部
     * @param
     * @return
     */
    @GetMapping("/all")
    public Result<List<YddAdvpos>> allAdvpos(){
        return iYddAdvposService.allAdvpos();
    }


    /**
     * 新增广告位
     * @param yddAdvposDTO
     * @return
     */
    @PostMapping("/add")
    public Result insertAdvpos(@RequestBody YddAdvposDTO yddAdvposDTO){
        return iYddAdvposService.insertAdvpos(yddAdvposDTO);
    }
}
